import { BasePaginationDto } from '@nbase/nest-mods';
import { ApiPropertyOptional } from '@nestjs/swagger';
import { IsIn, IsInt, IsOptional, IsString } from 'class-validator';
import { Type } from 'class-transformer';
import { DEPT_STATUS_VALUES, IQueryDept } from '@nbase/shared';

/**
 * 查询部门 DTO
 */
export class QueryDeptDto extends BasePaginationDto implements IQueryDept {
  @ApiPropertyOptional({
    description: '部门代码关键词',
    example: 'Test',
  })
  @IsOptional()
  @IsString()
  code?: string;

  @ApiPropertyOptional({
    description: '部门名称关键词',
    example: '测试部门',
  })
  @IsOptional()
  @IsString()
  name?: string;

  @ApiPropertyOptional({
    description: '状态（1.启用 2.禁用）',
    example: 1,
    enum: DEPT_STATUS_VALUES,
  })
  @IsOptional()
  @Type(() => Number)
  @IsInt()
  @IsIn(DEPT_STATUS_VALUES)
  status?: number;
}

